/**
 * DLA/Oscilloscope Project Software
 * 
 * By Kevin Cuzner <kevincuzner@yahoo.com>
 * 
 * This file is part of the DLA/Oscilloscope Project Software.
 *
 * The DLA/Oscilloscope Project Software is free software: you can 
 * redistribute it and/or modify it under the terms of the GNU Lesser
 * General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * The DLA/Oscilloscope Project Software is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with The DLA/Oscilloscope Project Software.
 * If not, see <http://www.gnu.org/licenses/>.
 */

using System;
using System.Collections.Generic;

namespace DLAOscilloscopegtk
{
	/**
	 * Contains a collection of samples with associated data
	 * In order to overcome the bandwidth restrictions of USB, the hardware
	 * will return samples by 'Window'. Each window contains a set number of
	 * samples which have been collected in sequential order after a set delay
	 * after a set trigger has been met. This class will be returned by a class
	 * implementing ISampleSource.
	 */
	public class SampleWindow
	{
		protected List<Sample> samples; //reference to the samples in this window
		protected SampleType type; //the type of samples this window has in it
		protected ulong frequency; //the sample frequency
		protected List<ChannelMapping> channelMappings; //the channel mappings for this samplewindow
		
		/**
		 * Constructor
		 * @param s reference to a List<Sample> of samples to assign to this window
		 * @param t the type of data associated with this samplewindow
		 * @param f the sampling frequency of the data
		 * @param channelMaps the channel groupings associated with this samplewindow
		 */
		public SampleWindow (List<Sample> s, SampleType t, ulong f, List<ChannelMapping> channelMaps)
		{
			this.samples = s;
			this.type = t;
			this.frequency = f;
			this.channelMappings = channelMaps;
		}
		
		/**
		 * Returns the channel mapping for the specified channel. If the channel does not exist it will return null
		 * @param channel The channel to get the mapping for
		 * @returns The channel mapping for this channel
		 */
		public ChannelMapping GetChannelMapping (uint channel)
		{
			if (channel >= this.channelMappings.Count)
				return null;
			
			return this.channelMappings [(int)channel];
		}
		
		public int NumChannels {
			get {
				return this.channelMappings.Count;
			}
		}
		public SampleType Type {
			get {
				return this.type;
			}
		}
		public ulong Frequency {
			get {
				return this.frequency;
			}
		}
	}
}

